<template>
  <div id="con">
    <div id="container" ref="map"></div>
  </div>
</template>

<script>
  export default {
    methods: {
      createMap() {
        var map = new AMap.Map("container", {
          resizeEnable: true,
          center: [110.287819,25.094553],//地图中心点
          zoom: 13 //地图显示的缩放级别
        });
        //构造路线导航类
        AMap.plugin(['AMap.Driving'],function () {})
        var driving = new AMap.Driving({
          map: map,
          // panel: "panel"
        });
        // 根据起终点经纬度规划驾车导航路线
        // var start = this.$store.state.address[start]
        // var end = this.$store.state.address.end
        // console.log(start)
        driving.search(new AMap.LngLat(110.287819,25.094553), new AMap.LngLat(110.28833,25.218951), function (status, result) {
          // result 即是对应的驾车导航信息，相关数据结构文档请参考  https://lbs.amap.com/api/javascript-api/reference/route-search#m_DrivingResult
          if (status === 'complete') {
            console.log('绘制驾车路线完成')
          } else {
            console.log('获取驾车数据失败：' + result)
          }
        });
      }
    },
    mounted() {
      this.createMap()

    }
  }

</script>
<style>

  #con {
    height: 100%;
  }
  #container {
    height: 100%;
  }
</style>
